<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text" placeholder="请输入1——100之间的整数">
<input type="button" value="猜一猜" onclick="guess()">
<h1>结果：<span></span></h1>
<script>
  //获取1——100之间的随机整数
  let randnum = parseInt(Math.random()*100)+1;
  let i= document.querySelector("input");
  let  s = document.querySelector("span");
  let times=0
  function guess(){
    times++;
    if (i.value*1>randnum){
      s.innerText="大了"
    }else if (i.value*1<randnum){
      s.innerText="小了"
    }else {
      s.innerText="恭喜你，第"+times+"次猜对了！"
    }

  }
</script>

</body>
</html>